home *** CD-ROM | disk | FTP | other *** search
- /* rectangles using long integers instead of short integers
- 93/12/17 aih created */
-
- #include <limits.h>
- #include "LongRectangleLib.h"
- #include "RectangleLib.h"
-
- #define ShortValid(n) (SHRT_MIN <= (n) && (n) <= SHRT_MAX)
-
- Boolean LRectValid(const LRectType *r)
- {
- return(r->top <= r->bottom && r->left <= r->right);
- }
-
- void LRectToRect(const LRectType *lr, Rect *r)
- {
- require(LRectValid(lr));
- require(ShortValid(lr->top) && ShortValid(lr->left));
- require(ShortValid(lr->bottom) && ShortValid(lr->right));
- r->top = lr->top; r->left = lr->left;
- r->bottom = lr->bottom; r->right = lr->right;
- ensure(RectValid(r));
- }
-
- void LRectFromRect(LRectType *lr, const Rect *r)
- {
- require(RectValid(r));
- lr->top = r->top; lr->left = r->left;
- lr->bottom = r->bottom; lr->right = r->right;
- ensure(LRectValid(lr));
- }
-
- void LRectOffset(LRectType *r, long h, long v)
- {
- require(LRectValid(r));
- r->top += v; r->left += h;
- r->bottom += v; r->right += h;
- ensure(LRectValid(r));
- }
-
- long LRectWidth(const LRectType *r)
- {
- require(LRectValid(r));
- return(r->right - r->left);
- }
-
- long LRectHeight(const LRectType *r)
- {
- require(LRectValid(r));
- return(r->bottom - r->top);
- }
-
-